package com.fp.m7.model;

import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.index.Indexed;

import com.google.common.base.Objects;

public class Follow {

	@Indexed
	private ObjectId followedId;
	private Long auditCD;
	private Long auditDD; // if =! null means this follow subscription is over

	public ObjectId getFollowedId() {
		return followedId;
	}

	public void setFollowedId(ObjectId followedId) {
		this.followedId = followedId;
	}

	public Long getAuditCD() {
		return auditCD;
	}

	public void setAuditCD(Long auditCD) {
		this.auditCD = auditCD;
	}

	public Long getAuditDD() {
		return auditDD;
	}

	public void setAuditDD(Long auditDD) {
		this.auditDD = auditDD;
	}

	@Override
	public String toString() {
		return new StringBuilder("Follow [followedId").append(followedId) //
				.append("; auditCD=").append(auditCD) //
				.append("; auditDD=").append(auditDD).append("]").toString();
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (obj instanceof Follow) {
			Follow that = (Follow) obj;
			return Objects.equal(this.auditCD, that.auditCD) //
					&& Objects.equal(this.auditDD, that.auditDD) //
					&& Objects.equal(this.followedId, that.followedId);
		}
		return false;
	}

	@Override
	public int hashCode() {
		return Objects.hashCode(auditCD, auditDD, followedId);
	}

}
